use crate::helpers::{Bot, Config};
use ::db::Db;
use anyhow::{Context, Result};
use tracing::info;
// use db::models::MatrixOrTelegramId;
use teloxide::prelude::*;
pub async fn start(_bot: Bot, m: Message, db: Db, _config: Config) -> Result<()> {
    let telegram_user = m.from().context("NoneError")?;
    let user_id = telegram_user.id;
    let user_username = &telegram_user.username;
    // let user_username = telegram_user.username.clone();
    // let user_id = MatrixOrTelegramId::TelegramId { id: user_id, username: user_username };
    info!("checking user {user_id}");
    match db.find_user_tg(&user_id).await? {
        Some(_) => {}
        None => {
            db.create_user_tg(&user_id, user_username).await?;
        }
    }

    Ok(())
}
